package com.ubtechinc.cruzr.launcher2.presenter;

import com.ubtechinc.cruzr.launcher2.callback.SettingListener;
import com.ubtechinc.cruzr.launcher2.model.entity.AppInfo;
import com.ubtechinc.cruzr.launcher2.model.AppManger;
import com.ubtechinc.cruzr.launcher2.model.helper.LoadHelper;
import com.ubtechinc.cruzr.launcher2.view.SettingView;

import java.util.List;

public class SettingPresenter implements SettingListener {
    private SettingView mSettingView;
    public SettingPresenter(SettingView view){
        mSettingView = view;
        AppManger.get().setSttingsListener(this);
    }
    public void unBindView(){
        mSettingView = null;
        AppManger.get().setSttingsListener(null);
    }
    public List<AppInfo> getData(){
        if(LoadHelper.getAllAppList().isEmpty()){
            AppManger.get().loadApps(true, false);
        }
        return LoadHelper.getAllAppList();
    }
    @Override
    public void onAllApppdate(List<AppInfo> list) {
        if(mSettingView != null){
            mSettingView.onAllApppdate(list);
        }
    }
}
